<?php 
include "includes/session.php";
include "includes/comunes.php";
$items=15;
$tabla="guiastransporte";
$condicion=" guiaID=".$_GET['gui_id'];
$orden="";
$eje=  cons_sql($tabla, $condicion, $orden);
$regGuia=  mysql_fetch_array($eje);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sistema de Registro de Atencion</title>

<link href="estilos.css" rel="stylesheet" type="text/css" />

<!--libreria jquery central-->
<script src="jquery-ui/js/jquery-1.9.1.js"></script>
<!--fin libreria central-->

<!--Librerias para el combo-->
<script language="JavaScript" type="text/javascript" src="combos/jquery.chainedSelects.js"></script>
<!--fin libreria-->

<!--librerias ui-->
<link href="jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css" rel="stylesheet"/>
<script src="jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<!--fin libreria-->


<script language="JavaScript" type="text/javascript">
$(function()
{

//        funcion que implementa combos
	$('#tipopedido').chainSelect('#estado','combobox.php',
	{
		before:function (target) //before request hide the target combobox and display the loading message
		{
			$("#loading").css("display","block");
			$(target).css("display","none");
		},
		after:function (target) //after request show the target combobox and hide the loading message
		{
			$("#loading").css("display","none");
			$(target).css("display","inline");
		}
	});
//        fin funcion

//          funcion que implementa autocompletado de articulos
     



		
		$( "#chofer" ).autocomplete({
			source: "autoGuias.php"
		});
              

//          fin funcion







//              funcion para validacion de formularios

             $("#pedido").submit(function () {

                if($("#numero").val() == 0) {
                    alert("Debe ingresar el numero de guia");
                    return false;
                }

            

                 if($("#remito1").val().length < 1)
                 {
                            alert("Debe ingresar por lo menos un remito");
                            return false;
                 }
          
            
        });

//              fin funcion
       $( "#menu" ).menu({position: {at: "left bottom"}});

});
</script>

</head>

<body>

<div class="container">
<?php include "includes/head.php"?>
   <div class="content">
       <div class="tituloprincipal"><img src="img/editar.png" width="25" height="25" border="0"/> Modificar Guia de Transporte
           <?php include 'includes/submenu.php';?>  
           </div>
       <form id="pedido" name="pedido" method="POST" action="editarGuia.php">
       <div class="contenedorpedido">
        <fieldset>
             <legend><b>Datos de Cabecera</b></legend>
             <table>
                 <tr>
                     <td class="textotablamenuform">Punto</td>
                     <td class="textotablamenuform">
                         <input type="text" name="punto" id="punto" size="15" value="<?php echo $regGuia['guiaPunto']?> "  class="campo_form" disabled/>
                            <input type="hidden" name="gui_id" id="gui_id" size="15" value="<?php echo $regGuia['guiaId']?> "  class="campo_form" disabled/>

                     </td>
                     <td class="textotablamenuform">Nro. Guia</td>
                     <td class="textotablamenuform">
                          <input type="text" name="numero" id="numero" size="15" value="<?php echo $regGuia['guiaNumero']?> "  class="campo_form" disabled/>
                     </td>
                     <td class="textotablamenuform">Usuario</td>
                     <td class="textotablamenuform">
                         <input type="text" name="usuario" value="<?php echo obtener_usuario($regGuia['guiaUsuario']) ?> " disabled class="campo_form" disabled/>
                     </td>
                 </tr>
                 <tr>
                     <td class="textotablamenuform">Origen</td>
                     <td class="textotablamenuform">
                        <select name="origen" id="origen" class="campo_form" disabled>
                             
                             <?php
                             $ped=obtener_sucursales();

                             while($regPed=mysql_fetch_array($ped)){
                                 if($regGuia['guiaOrigen']==$regPed['sucursalId'])
                                       echo "<option value='".utf8_encode($regPed['sucursalId'])."' selected>".utf8_encode($regPed['sucursalNombre'])." (".utf8_encode($regPed['sucursalCodigo']).")</option>";

                                     else
                                         echo "<option value='".utf8_encode($regPed['sucursalId'])."'>".utf8_encode($regPed['sucursalNombre'])." (".utf8_encode($regPed['sucursalCodigo']).")</option>";


                             }

                             ?>

                         </select>
                     </td>
                     <td class="textotablamenuform">Destino</td>
                     <td class="textotablamenuform">
                          <select name="destino" id="destino" class="campo_form" disabled>
                             
                             <?php
                             $ped=obtener_sucursales();

                             while($regPed=mysql_fetch_array($ped)){
                              if($regGuia['guiaDestino']==$regPed['sucursalId'])
                                       echo "<option value='".utf8_encode($regPed['sucursalId'])."' selected>".utf8_encode($regPed['sucursalNombre'])." (".utf8_encode($regPed['sucursalCodigo']).")</option>";

                                     else
                                         echo "<option value='".utf8_encode($regPed['sucursalId'])."'>".utf8_encode($regPed['sucursalNombre'])." (".utf8_encode($regPed['sucursalCodigo']).")</option>";
  }

                             ?>

                         </select>
                     </td>
                     <td class="textotablamenuform">Fecha</td>
                     <td class="textotablamenuform">
                         <input type="text" disabled name="fecha" value="<?php echo $regGuia['guiaFecha'] ?>" class="campo_form" disabled/>
                     </td>
                 </tr>

                  <tr>
                     <td class="textotablamenuform">Chofer</td>
                     <td class="textotablamenuform">
                      <input type="text" name="chofer" disabled id="chofer" value="<?php echo $regGuia['guiaChofer'] ?>" class="campo_form"/>
                     </td>
                     <td class="textotablamenuform">Pat. Tractor</td>
                     <td class="textotablamenuform">
                    <input type="text" name="patenteTractor" disabled id="patenteTractor" value="<?php echo $regGuia['guiaPatenteTractor'] ?>" class="campo_form"/>
                     </td>
                     <td class="textotablamenuform">Pat. Semi</td>
                     <td class="textotablamenuform">
                        <input type="text" name="patenteSemi" disabled id="patenteSemi" value="<?php echo $regGuia['guiaPatenteSemi'] ?>" class="campo_form"/>   </td>
                 </tr>

                 <tr>
                    <td class="textotablamenuform">Observacion</td>
                    <td class="textotablamenuform" colspan="5"><textarea disabled rows="3" cols="71" class="campo_form" id="observacion" name="observacion"><?php echo $regGuia['guiaObservacion'] ?></textarea></td>
                 </tr>
             </table>
        </fieldset>
           <fieldset>
             <legend><b>Detalle de Remitos</b></legend>
              <table>
                 <tr>
                     <td class="textotablamenuform" colspan="2">Remito</td>
                 
                     <td class="textotablamenuform">Observacion</td>
                       </tr>

                   <?php
                       $can=1;//variable que cuenta cuantos codigos hay cargados
                       $tabladet="guiatransportedetalle";
                       $condiciondet=" detalleGuiaId=".$regGuia['guiaId'];
                       $ordendet=" order by detalleItem asc ";
                       $ejedet=  cons_sql($tabladet, $condiciondet, $ordendet);

                       while($regdet=  mysql_fetch_array($ejedet)): ?>
                        <tr>

                     <td class="textotablamenuform"  colspan="2">

                     <input type="text" disabled value="<?php echo $regdet['detalleRemito']?>" name="remito<?php echo $can?>" id="remito<?php echo $can?>"  class="campo_form" size="85"/></td>

                      <td class="textotablamenuform">
                       <input type="text" disabled value="<?php echo $regdet['detalleObservacion']?>" name="observaremito<?php echo $can?>" id="observaremito<?php echo $can?>" value="" class="campo_form" /></td>

                    </tr>


                      <?php
                      $can++;
                      endwhile ?>



               

<!--                <tr>

                     <td class="textotablamenuform" style="text-align: right;" colspan="5">
                         <input type="reset" name="enviar" value="Restablecer"  class="boton_form"/>
                         <input name="submit" id="submit" type="submit" value="Guardar Pedido" class="boton_form"/>
                     </td>

                 </tr>-->

             </table>
        </fieldset>
           
       </div>
   </form>
       <div class="clear"></div>
   <br>
   </div>
  <?php include "includes/pie.php"?>
  
</div>
</body>
</html>
